﻿<UserControl x:Class="Workbench.Presentation.ConcordancerView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:uc="clr-namespace:Workbench.Presentation.UserContols" 
             xmlns:ui="clr-namespace:Workbench.Presentation" 
             mc:Ignorable="d" >
    <UserControl.Resources>
        <ui:EnumToBoolConverter x:Key="enumConverter" />
    </UserControl.Resources>
    <DockPanel MinWidth="600">
        <Grid DockPanel.Dock="Bottom" HorizontalAlignment="Center">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="250"></ColumnDefinition>
                <ColumnDefinition Width="150"></ColumnDefinition>
                <ColumnDefinition Width="150"></ColumnDefinition>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="300"></RowDefinition>
            </Grid.RowDefinitions>
            <GroupBox Margin="5 0" Header="Selection" Padding="5">
                <DockPanel>
                    <RadioButton 
                        DockPanel.Dock="Top" 
                        GroupName="SelectionForm" 
                        IsChecked="{Binding Path=SuggestionType, 
                                            Converter={StaticResource enumConverter},
                                            ConverterParameter=WordForm}" 
                        Margin="5 5 5 0" 
                        Content="Word Form"></RadioButton>
                    <RadioButton
                        DockPanel.Dock="Top" 
                        GroupName="SelectionForm" 
                        IsChecked="{Binding Path=SuggestionType, 
                                            Converter={StaticResource enumConverter}, 
                                            ConverterParameter=BaseForm}" 
                        Margin="5 0 5 5" 
                        Content="Base Form"></RadioButton>

                    <TextBox DockPanel.Dock="Top" Text="{Binding Path=CurrentSearchContent,UpdateSourceTrigger=PropertyChanged}"></TextBox>
                    <ListBox DockPanel.Dock="Top" ItemsSource="{Binding Path=SuggestedWords}" SelectedItem="{Binding Path=SelectedWordSuggestion, Mode=TwoWay}">
                        <ListBox.ItemTemplate>
                            <DataTemplate>
                                <TextBlock Text="{Binding Content}"></TextBlock>
                            </DataTemplate>
                        </ListBox.ItemTemplate>
                    </ListBox>
                </DockPanel>
            </GroupBox>
            <StackPanel Margin="5 0" Grid.Column="1">
                <GroupBox Header="Sorting options">
                    <StackPanel>
                        <StackPanel Margin="0 10"  Orientation="Horizontal" HorizontalAlignment="Center">
                            <Button Command="{Binding DownCommand}" Content="-" Margin="5 0" Padding="5 0"></Button>
                            <TextBox IsReadOnly="True" Margin="5 0" Padding="5 0" Text="{Binding SortingColumn}"></TextBox>
                            <Button Command="{Binding UpCommand}" Content="+" Margin="5 0" Padding="5 0"></Button>
                        </StackPanel>

                        <RadioButton 
                        DockPanel.Dock="Top" 
                        GroupName="SortingType" 
                        IsChecked="{Binding Path=SortingType, 
                                            Converter={StaticResource enumConverter},
                                            ConverterParameter=Alphabetically}" 
                                    Margin="5 5 5 0" 
                                    Content="Alphabetically"></RadioButton>
                        <RadioButton
                        DockPanel.Dock="Top" 
                        GroupName="SortingType" 
                        IsChecked="{Binding Path=SortingType, 
                                            Converter={StaticResource enumConverter}, 
                                            ConverterParameter=Frequency}" 
                                    Margin="4,0,6,5" 
                                    Content="Frequency"></RadioButton>
                        <Button Content="Sort" Command="{Binding SortCommand}" HorizontalAlignment="Center" Padding="10 0" Margin="0 10"></Button>
                    </StackPanel>
                </GroupBox>
            </StackPanel>
        </Grid>
        <ListBox DockPanel.Dock="Top" ItemsSource="{Binding Words}" MinHeight="100" SelectionMode="Extended">
            <ListBox.ItemContainerStyle>
                <Style TargetType="{x:Type ListBoxItem}">
                    <Setter Property="IsSelected" Value="{Binding IsSelected}" />
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid HorizontalAlignment="Center">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                            <ColumnDefinition Width="100"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBlock Margin="10 0" Grid.Column="0" Text="{Binding LeftWord5}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="1" Text="{Binding LeftWord4}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="2" Text="{Binding LeftWord3}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="3" Text="{Binding LeftWord2}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="4" Text="{Binding LeftWord1}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="5" Text="{Binding WordContent}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="6" Text="{Binding RightWord1}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="7" Text="{Binding RightWord2}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="8" Text="{Binding RightWord3}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="9" Text="{Binding RightWord4}"></TextBlock>
                        <TextBlock Margin="10 0" Grid.Column="10" Text="{Binding RightWord5}"></TextBlock>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
    </DockPanel>
</UserControl>
